{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#多维数组的索引和切片(作业名称)\n",
    "\n",
    "---\n",
    "个人信息:  \n",
    "- 姓名: 王续龙\n",
    "- 年级: 2020\n",
    "- 专业: 智能科学与技术\n",
    "- 班级: 1班\n",
    "---\n",
    "\n",
    "- 诚信守则:  \n",
    "    - 我承诺该报告内容**为我个人书写非直接抄袭所得。**\n",
    "    - 我**可以解释答题思路并复现我的答案。**\n",
    "    - 如无法实现以上要求，**我愿意承担由此带来的后果。**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'tabulate'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-2-3474f89ba7af>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mnumpy\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtabulate\u001b[0m  \u001b[0;32mimport\u001b[0m \u001b[0mtabulate\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      3\u001b[0m \u001b[0ma\u001b[0m  \u001b[0;34m=\u001b[0m  \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m89\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      4\u001b[0m \u001b[0ma1\u001b[0m  \u001b[0;34m=\u001b[0m  \u001b[0ma\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      5\u001b[0m \u001b[0ma2\u001b[0m  \u001b[0;34m=\u001b[0m  \u001b[0ma\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'tabulate'"
     ]
    }
   ],
   "source": [
    "!pip install tabu\n",
    "import numpy as np\n",
    "from tabulate  import tabulate\n",
    "a  =  np.arange(0,89,2).reshape((3,5,3))\n",
    "a1  =  a[1,2,2]\n",
    "a2  =  a[1:2,2:3,2:3]\n",
    "    \n",
    "a3  =  a[1,1]\n",
    "  \n",
    "a4  =  a[ 1:2,1:2,:]\n",
    "\n",
    "a5  =  a[:,3,:]\n",
    "\n",
    "a6  =  a[:,3:4,:]\n",
    "\n",
    "a7  =  a[1:,3:,1]\n",
    "\n",
    "a8  =  a[:,-1::-2]\n",
    "\n",
    "\n",
    "result=[\n",
    "        ['array','ndim','shape','result'],\n",
    "        ['a',a.ndim,a.shape,tabulate(a,tablefmt='grid')],\n",
    "        ['a1',a1.ndim,a1.shape,a1],\n",
    "        ['a2',a2.ndim,a2.shape,tabulate(a2,tablefmt='grid')],\n",
    "        ['a3',a3.ndim,a3.shape,a3],\n",
    "        ['a4',a4.ndim,a4.shape,tabulate(a4,tablefmt='grid')],\n",
    "        ['a5',a5.ndim,a5.shape,tabulate(a5,tablefmt='grid')],\n",
    "        ['a6',a6.ndim,a6.shape,tabulate(a6,tablefmt='grid')],\n",
    "        ['a7',a7.ndim,a7.shape,tabulate(a7,tablefmt='grid')],\n",
    "        ['a8',a8.ndim,a8.shape,tabulate(a8,tablefmt='grid')]\n",
    "]      \n",
    "print(tabulate(result,headers='firstrow', tablefmt='grid'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
